package com.fulihui.usercore.core.repository;

import com.fulihui.usercore.condition.UserCondition;
import com.fulihui.usercore.dto.UserDTO;
import com.fulihui.usercore.enums.BooleanValueEnum;

import java.util.List;
import java.util.Map;

/**
 * @author Willard.Hu on 2016/5/19.
 */
public interface UserRepository {

    /**
     * 创建用户，uid由序列化工具生成，执行完创建方法后返回uid
     * @param userDTO {@link UserDTO}
     * @return uid
     */
    String create(UserDTO userDTO);

    boolean modify(UserDTO userDTO);

    boolean updateMobileNo(String mobileNo, String userId, BooleanValueEnum verified);

    boolean updateIdcard(String idcard, String userId, BooleanValueEnum verified);

    boolean updateEmail(String email, String userId, BooleanValueEnum verified);

    /**
     * 更新用户状态
     * @param state 状态值 {@link com.fulihui.usercore.enums.UserStateEnum#getCode()}
     * @param userId 用户唯一标识
     * @return 更新结果
     */
    boolean updateState(String state, String userId);

    UserDTO queryByPK(String userId);

    UserDTO queryByLoginId(String loginId);

    List<UserDTO> queryByUserIds(List<String> userIds);

    Map<String, UserDTO> queryByUserIdsToMap(List<String> userIds);

    /**
     * 用户昵称精准查询，昵称加密了，不能模糊查询
     * @param nickname 昵称
     * @return 查询到的结果 {@link UserDTO}
     */
    List<UserDTO> queryByNickname(String nickname);

    List<UserDTO> queryPage(int start, int rows, UserCondition condition);

    long totalCount(UserCondition condition);
}
